import { ref } from 'vue';
import { getDeviceCategoryApi, getDeviceListApi } from '@/service/api/businessApi';

export function deviceHooks() {
  const deviceCategoryList = ref([]);

  const getDeviceList = async (params: any) => {
    const res = await getDeviceListApi({ pageNo: 1, pageSize: 1000, ...params });
    if (res?.data?.data) return res.data.data;
    return [];
  };

  const getDeviceCategory = async (params: any) => {
    const res = await getDeviceCategoryApi({ pageNo: 1, pageSize: 1000, ...params });
    if (res?.data?.data) deviceCategoryList.value = res.data.data;
  };

  return {
    getDeviceList,
    getDeviceCategory,
    deviceCategoryList
  };
}
